package com.fsnbigdata.repository;

import com.fsnbigdata.domain.ZhEcologyNav;
import org.hibernate.annotations.OnDelete;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface ZhEcologyNavRepository extends JpaRepository<ZhEcologyNav,Long>{
    Page<ZhEcologyNav> findAll(Specification specification, Pageable pageable);

    @Override
    List <ZhEcologyNav> findAll(Sort sort);

    @Query(value = "select city from ZhEcologyNav group by city")
    List<String> findAllCity();

    @Query(value = "select category,count(id) from ZhEcologyNav group by category")
    List<Object> countType();

    @Query(value = "select category,count(id) from ZhEcologyNav where city = ?1" )
    List<Object> countTypeByCity(String city);

    @Query(value = "select * from zh_ecology_nav where initial=?1",nativeQuery = true)
    List<ZhEcologyNav> queryByAlphabet(String s);
}
